<?php

namespace Admin\Controller;
use Common\Controller\BackendController;
class NavController extends BackendController {

    protected function _search() {
        $map['type'] = $this->_get('type', 'trim', 'main');
        return $map;
    }

    public function _before_index() {
        $this->sort = 'ordid';
        $this->order = 'ASC';
        $big_menu = array(
            'title' => L('nav_add'),
            'iframe' => U('Nav/add'),
            'id' => 'add',
            'width' => '500',
            'height' => '200'
        );
        $this->assign('big_menu', $big_menu);
    }
    
    public function ajax_upload()
    {
    	$type = $this->_get('type', 'trim', 'img');
    	if (!empty($_FILES[$type]['name'])) {
    		$dir = date('ym/d/');
    		$result = $this->_upload($_FILES[$type], 'm/' . $dir);
    		if ($result['error']) {
    			$this->ajaxReturn(0, $result['info']);
    		} else {
    			$savename = $dir . $result['info'][0]['savename'];
    			$this->ajaxReturn(1, L('operation_success'), $savename);
    		}
    	} else {
    		$this->ajaxReturn(0, L('illegal_parameters'));
    	}
    }
}